<?php
set_time_limit(0);
error_reporting(E_ALL);
include 'config.php';

$mysqli = new mysqli($dbhost, $dbuser, $dbpwd, $dbName);
if (!$mysqli->set_charset("utf8")) {printf("Error loading character set utf8: %s\n", $mysqliTwo->error);}
 
$nianji='四年级';
$sql="select openid,createtime from ci3 where miao < 1 order by fen desc limit 0,800  ";
$query =$mysqli->query($sql);
 
while ($list=$query->fetch_assoc()){
     
    $endTime=strtotime($list['createtime']);
    
    $sql="select createtime from ci3_log where openid='".$list['openid']."' order by id desc limit 0,1 ";
    $getquery =$mysqli->query($sql);
    if($getquery->num_rows>0){
        $getData=$getquery->fetch_assoc();
        $startTime=strtotime($getData['createtime']);
        $cha=$endTime - $startTime;
        if ($cha > 900){
            $cha=900-rand(10,20);
        }
        echo "update ci3 set miao=".$cha." where openid='".$list['openid']."';" ;
        echo "<br />";
    }
    
     
}